//
//  ShoppingCartModel.swift
//  CJXSwiftStoryboard
//
//  Created by CJX on 2016/10/22.
//  Copyright © 2016年 caijianxi. All rights reserved.
//

import UIKit

class ShoppingCartModel: NSObject {
    
    var products_image : String?
    var products_name : String?
    
    var products_options_values_name : String?
    var options_values_id : String?
    var options_id : String?
    
    
    var format_price : String?
    var format_total_price : String?
    var quantity : String?
    var products_id : String?
    var id : String?
    
    
    init(dictionary:NSDictionary){
        products_image = dictionary["products_image"]as?String
        products_name = dictionary["products_name"]as?String
        let arr = dictionary["attributes"] as? NSArray
        
        products_options_values_name = (arr?.firstObject as! NSDictionary)["products_options_values_name"] as? String
        options_values_id = (arr?.firstObject as! NSDictionary)["options_values_id"] as? String
        if options_values_id == nil{
            options_values_id = String(Int(((arr?.firstObject as! NSDictionary)["options_values_id"] as? NSNumber)!))
        }
        let opIDNumber = (arr?.firstObject as! NSDictionary)["options_id"] as? NSNumber
        options_id = String(Int(opIDNumber!))

        
        format_price = dictionary["format_price"]as?String
        format_total_price = dictionary["format_total_price"]as?String
        quantity = String(describing: dictionary["quantity"]!)
        products_id = String(describing: dictionary["products_id"]!)
        id = dictionary["id"]! as? String
        
    }

}
